package ar.edu.unlam.tpfinal.result;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ProcessResult {
	
	private List<Map<String,String>> errorList;

	private String processError;
	
	public List<Map<String, String>> getErrorList() {
		return errorList;
	}

	public void addError(String key, String value) {
		if(errorList == null) {
			errorList = new ArrayList<Map<String,String>>();
		}
		Map<String, String> errorMap = new HashMap<String, String>();
		errorMap.put(key, value);
		errorList.add(errorMap);
	}
	
	public boolean isError() {
		if((errorList != null && errorList.size() > 0) || (this.processError != null && this.processError.length()>0)) {
			return true;
		}
		return false;
	}

	public String getProcessError() {
		return processError;
	}

	public void addProcessError(String processError, Exception e) {
		this.processError = processError;
		this.processError.concat("\nError:");
		this.processError.concat("\n\t" + e.getMessage());
	}
	
}
